module.exports = function (mongoose, Schema, ObjectId) {
  let commentSchema = new Schema({
    content: {
      type: String,
      required: [true, '缺少内容。'],
      maxlength: [300, '评论太长了。']
    },
    author: {
      type: ObjectId,
      ref: 'User'
    },
    anonym: {
      name: {type: String, default: '匿名', maxlength: [16, '昵称太长了。']},
      email: {type: String, maxlength: [30, '电子邮箱太长了。']},
      homepage: {type: String, maxlength: [50, '个人主页太长了。']}
    },
    Blog: {
      type: ObjectId,
      ref: 'Blog',
      required: true
    },
    artcle: {
      type: ObjectId,
      ref: 'Artcle',
      required: true
    },
    createAt: {
      type: Date,
      default: Date.now
    },
    updateAt: {
      type: Date,
      default: Date.now
    }
  })

  return mongoose.model('Comment', commentSchema)
}
